package com.github.llyb120.calengine.method;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.github.llyb120.calengine.rule.RuleEngine;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class ExposeFunc extends AbstractScriptFunc {

    public ExposeFunc(RuleEngine ruleEngine) {
        super(ruleEngine);
    }

    @Override
    public Object call(Object... args) {
        List list = Arrays.stream(args).collect(Collectors.toList());
        return JSON.toJSONString(list, SerializerFeature.DisableCircularReferenceDetect, SerializerFeature.PrettyFormat);
    }
}
